package com.baturu.vin.honda.dal.dao;

import com.baturu.vin.dto.superEPC.SEPCGroupDTO;
import com.baturu.vin.honda.dto.SEPCHondaImageDTO;
import com.baturu.vin.honda.dto.SEPCHondaSubGroupDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @Author: chenjiahao
 * @Time: 2019/5/8
 */
public interface SEPCHondaGroupDAO {
    @Select({"SELECT DISTINCT nplgrp mainGroupCode, concat(nplgrp,' ',xplgrp) mainGroup FROM HONDA_PGROUT WHERE disk = ''"})
    List<SEPCGroupDTO> queryMainGroup();

    @Select({"SELECT DISTINCT  main_group_code,  main_group FROM HONDA_PGROUT_CN WHERE id<10"})
    List<SEPCGroupDTO> queryMainGroupForCN();

    @Select({"<script>SELECT DISTINCT  main_group_code, concat(main_group_code,' ',main_group) mainGroup FROM HONDA_PGROUT_CN ",
            "WHERE main_group_code in ",
            "<foreach item='item' index='index' collection='codes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<SEPCGroupDTO> queryMainGroupByCodes(@Param("codes") Collection<String> codes);

    @Select({"SELECT DISTINCT nplblk, nplblkedit FROM honda_pblokt",
            "WHERE npl = #{npl}",
            "AND disk = #{disk}",
            "AND nplgrp = #{nplgrp}"
    })
    List<SEPCHondaSubGroupDTO> querySubCode(@Param("nplgrp") String nplgrp, @Param("npl") String npl, @Param("disk") String disk);

    @Select({"<script>",
            "SELECT",
            "nplblk",
            "FROM honda_pblmtt",
            "WHERE",
            "npl=#{npl}",
            "AND hmodtyp = ${hmodtyp}",
            "AND disk = #{disk}",
            "</script>"})
    Set<String> getNplblkByVin(@Param("npl")String npl, @Param("hmodtyp")String hmodtyp, @Param("disk") String disk);

    @Select({"<script>SELECT xplblk,nplblk FROM honda_pbldst",
            "WHERE npl = #{npl}",
            "AND nplblk in ",
            "<foreach item='item' index='index' collection='nplblks' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "AND disk = #{disk}",
            "</script>"})
    List<SEPCHondaSubGroupDTO> querySubDes(@Param("npl") String npl, @Param("nplblks") Collection<String> nplblks, @Param("disk") String disk);

    @Select({"<script>SELECT illustrationNumber, partReferenceNumber, max_x,max_y,min_x,min_y, npl ",
            "FROM honda_parts_image",
            "WHERE illustrationNumber in",
            "<foreach item='item' index='index' collection='nplblks' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "AND disk = #{disk}",
            "AND npl = #{npl}",
            "</script>"})
    List<SEPCHondaImageDTO> queryImageByGroup(@Param("npl") String npl, @Param("nplblks") Collection<String> nplblks, @Param("disk") String disk);

    @Select({"<script>SELECT DISTINCT nplblk, nplblkedit,nplgrp FROM honda_pblokt",
            "WHERE npl = #{npl}",
            "AND disk = #{disk}",
            "AND nplblk in",
            "<foreach item='item' index='index' collection='nplblks' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach></script>"})
    List<SEPCHondaSubGroupDTO> querySubCodeByNplgrp(@Param("nplblks") Collection<String> nplblks, @Param("npl") String npl, @Param("disk") String disk);
}
